package assql
{
	public class SQLDate
	{
		private var year:int;
		private var month:int;
		private var day:int;
		
		private var hours:Number;
		private var minutes:Number;
		private var seconds:Number;
		private var milliseconds:Number;
		
		//TODO Implement
		public function SQLDate(year:int, month:int, day:int, hours:Number=NaN, minutes:Number=NaN, seconds:Number=NaN, milliseconds:Number=NaN)
		{
			this.year = year;
			this.month = month;
			this.day;
			
			this.hours = hours;
			this.minutes = minutes;
			this.seconds = seconds;
			this.milliseconds = milliseconds;
		}
		
		public function getDate():Date {
			var dt:Date = new Date();
			dt.setFullYear(year, month, day);
			
			if ( !isNaN(hours) ) {
				dt.setHours(hours, minutes, seconds, milliseconds);
			}
			else {
				dt.setHours(0, 0, 0, 0);
			}
			
			return dt;
		}
		
		public function getTime():Number {
			return getDate().getTime();
		}
		
		public function isDateOnly():Boolean {
			return isNaN(hours);
		}
		
		public function setDate(year:int, month:int, day:int, hours:Number=NaN, minutes:Number=NaN, seconds:Number=NaN, milliseconds:Number=NaN):void {
			this.year = year;
			this.month = month;
			this.day;
			
			this.hours = hours;
			this.minutes = minutes;
			this.seconds = seconds;
			this.milliseconds = milliseconds;
		}
	}
}